﻿using System.Collections.Generic;
using System.Linq;
using Kaiser.Domains;

namespace Kaiser.Modules.Core.Aggregates
{
    public class Account : EntityBase<Account>
    {
        public Account() {
            Roles = new List<Role>();
        }

        public string UserName { get; set; }
        public string RealName { get; set; }
        public string Password { get; set; }
        public string Sex { get; set; }
        public string Age { get; set; }
        public bool IsEnable { get; set; }

        IList<Role> Roles { get; set; }

        public bool HasPrivilege(string privilegeId)
        {
            var list = Roles.Select(x => x.PrivilegeList.Count(f => f.PrivilegeId == privilegeId));
            if (list != null && list.Count() > 0)
            {
                return true;
            }
            return false;
        }
    }
}
